$OpenBSD: patch-src_main_radsniff_c,v 1.3 2016/01/25 20:32:15 sthen Exp $

OpenBSD libpcap uses nonstandard "bpf_timeval" variables which are a
different size to timeval on some arch..

This patch is enough to let it build but is incomplete and unlikely to
allow radsniff to actually work.

--- src/main/radsniff.c.orig	Mon Jan 25 18:27:03 2016
+++ src/main/radsniff.c	Mon Jan 25 20:09:38 2016
@@ -1000,7 +1000,8 @@ static inline int rs_request_to_pcap(rs_event_t *event
 #define RS_CLEANUP_NOW(_x, _s)\
 	{\
 		_x->silent_cleanup = _s;\
-		_x->when = header->ts;\
+		_x->when.tv_sec = header->ts.tv_sec;\
+		_x->when.tv_usec = header->ts.tv_usec;\
 		rs_packet_cleanup(_x);\
 		_x = NULL;\
 	} while (0)
@@ -1035,10 +1036,12 @@ static void rs_packet_process(uint64_t count, rs_event
 	memset(&search, 0, sizeof(search));
 
 	if (!start_pcap.tv_sec) {
-		start_pcap = header->ts;
+		start_pcap.tv_sec = header->ts.tv_sec;
+		start_pcap.tv_usec = header->ts.tv_usec;
 	}
 
 	if (RIDEBUG_ENABLED()) {
+		/* XXX convert pcap timeval */
 		rs_time_print(timestr, sizeof(timestr), &header->ts);
 	}
 
@@ -1132,11 +1135,13 @@ static void rs_packet_process(uint64_t count, rs_event
 	current = rad_alloc(conf, false);
 	if (!current) {
 		REDEBUG("Failed allocating memory to hold decoded packet");
+		/* XXX convert pcap timeval */
 		rs_tv_add_ms(&header->ts, conf->stats.timeout, &stats->quiet);
 		return;
 	}
 
-	current->timestamp = header->ts;
+	current->timestamp.tv_sec = header->ts.tv_sec;
+	current->timestamp.tv_usec = header->ts.tv_usec;
 	current->data_len = header->caplen - (p - data);
 	memcpy(&current->data, &p, sizeof(current->data));
 
@@ -1256,6 +1261,7 @@ static void rs_packet_process(uint64_t count, rs_event
 			 *	The delay is so we can detect retransmissions.
 			 */
 			original->linked = talloc_steal(original, current);
+			/* XXX convert pcap timeval */
 			rs_tv_add_ms(&header->ts, conf->stats.timeout, &original->when);
 			if (!fr_event_insert(event->list, _rs_event, original, &original->when,
 					     &original->event)) {
@@ -1336,6 +1342,7 @@ static void rs_packet_process(uint64_t count, rs_event
 		search.expect = rad_alloc_reply(current, current);
 		if (!search.expect) {
 			REDEBUG("Failed allocating memory to hold expected reply");
+			/* XXX convert pcap timeval */
 			rs_tv_add_ms(&header->ts, conf->stats.timeout, &stats->quiet);
 			rad_free(&current);
 			return;
@@ -1486,7 +1493,9 @@ static void rs_packet_process(uint64_t count, rs_event
 		/*
 		 *	Insert a callback to remove the request from the tree
 		 */
-		original->packet->timestamp = header->ts;
+		original->packet->timestamp.tv_sec = header->ts.tv_sec;
+		original->packet->timestamp.tv_usec = header->ts.tv_usec;
+		/* XXX convert pcap timeval */
 		rs_tv_add_ms(&header->ts, conf->stats.timeout, &original->when);
 		if (!fr_event_insert(event->list, _rs_event, original,
 				     &original->when, &original->event)) {
@@ -1507,6 +1516,7 @@ static void rs_packet_process(uint64_t count, rs_event
 		return;
 	}
 
+	/* XXX convert pcap timeval */
 	rs_tv_sub(&header->ts, &start_pcap, &elapsed);
 
 	/*
@@ -1536,6 +1546,7 @@ static void rs_packet_process(uint64_t count, rs_event
 		 *	Were filtering on response, now print out the full data from the request
 		 */
 		if (conf->filter_response && RIDEBUG_ENABLED() && (conf->event_flags & RS_NORMAL)) {
+			/* XXX convert pcap timeval */
 			rs_time_print(timestr, sizeof(timestr), &original->packet->timestamp);
 			rs_tv_sub(&original->packet->timestamp, &start_pcap, &elapsed);
 			rs_packet_print(original, original->id, RS_NORMAL, original->in,
@@ -1618,7 +1629,8 @@ static void rs_got_packet(fr_event_list_t *el, int fd,
 			}
 
 			do {
-				now = header->ts;
+				now.tv_sec = header->ts.tv_sec;
+				now.tv_usec = header->ts.tv_usec;
 			} while (fr_event_run(el, &now) == 1);
 			count++;
 
